package com.jacky.iot;

import org.eclipse.californium.core.coap.OptionSet;
import org.eclipse.californium.core.network.Exchange;
import org.eclipse.californium.core.server.DelivererException;
import org.eclipse.californium.core.server.ServerMessageDeliverer;
import org.eclipse.californium.core.server.resources.Resource;
import org.eclipse.californium.elements.config.Configuration;

public class CustomerMessageDeliverer extends ServerMessageDeliverer {
    /**
     * Constructs a default message deliverer that delivers requests to the
     * resources rooted at the specified root.
     *
     * @param root   the root resource
     * @param config the configuration
     * @since 3.6
     */
    public CustomerMessageDeliverer(Resource root, Configuration config) {
        super(root, config);
    }

    @Override
    protected Resource findResource(Exchange exchange) throws DelivererException {
        String uri = exchange.getRequest().getURI();
        OptionSet options = exchange.getRequest().getOptions();
        System.out.println("deviceId:"+options.getUriQueryParameter().getArgument("deviceId"));
        System.out.println("msg deliver uri:" + uri);
        return super.findResource(exchange);
    }
}
